#include <iostream>
#include <list>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
unordered_map<string, int> M;
signed main() {

	string s;
	while (cin >> s) {
		if (s != "O") M[s] ++;
		else break;
	}

	cout << "OK" << endl;
	vector<pair<string, int> > v;
	while (cin >> s) {
		if (M[s]) v.push_back({s, 1});
		else if (s == "O") break;
		else v.push_back({s, 0});
	}
	cout << s << endl;
	for (auto i : v) {
		cout << i.first << "\t" << i.second << endl;
	}
	system("pause");
	return 0;
}